//
// Created by EDZ on 2022/1/6.
//

#ifndef BASIC_SMART_POINTERS_H
#define BASIC_SMART_POINTERS_H
void func_use_pointer();
void func_smart_pointer();
void func_unsafe_pointer();
class Resource {
public:
    explicit Resource(int a);

    ~Resource() ;

    int getAge() const;

    void setAge(int a);
private:
    int age;
};

template<class T>
class smart_ptr{
private:
    T* m_ptr;
public:
    smart_ptr(T* ptr= nullptr):m_ptr{ptr} {}
    ~smart_ptr()
    {
        delete m_ptr;
    }
    T& operator*() const {return *m_ptr;}
    T* operator->() const {return m_ptr;}
};

#endif //BASIC_SMART_POINTERS_H
